<template>
  <div class="list-table">
    <el-table v-loading="loading" :data="dealPaymentDetailList" border>
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('基金简称')" align="center" prop="fundName" min-width="180" show-overflow-tooltip />
      <el-table-column :label="$t('实际付款时间')" align="center" prop="applyTime" min-width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.actualPaymentDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('出资人名称')" align="center" prop="userName" min-width="180" show-overflow-tooltip />
      <el-table-column :label="$t('出资人类型')" align="center" prop="investorsType" :formatter="investorsTypeOptionsFormat" min-width="140" show-overflow-tooltip />
      <el-table-column :label="$t('计算基数') + $t('(元/%)')" align="center" prop="calculationBase" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.calculationBase, 'rate') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('划款金额') + $t('金额单位')" align="center" prop="actualPaymentMoney" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.actualPaymentRateMoney, 'w') }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listDealPaymentDetail } from '@/api/deal/paymentDetail/dealPaymentDetail'
export default {
    components: {
    },
  data() {
      return {
          // 遮罩层
          loading: true,
          // 总条数
          total: 0,
          // 划款明细表格数据
          dealPaymentDetailList: [],
          investorsTypeOptions: [],
          // 弹出层标题
          title: '划款分摊明细',
          // 查询参数
          queryParams: {
              fundId: this.$route.query.id,
              dealPaymentId: undefined,
              dealPaymentInvestorId: undefined,
              investorId: undefined,
              pageNum: 1,
              pageSize: 10
          },
          // 表单参数
          form: {},
          // 表单校验
          rules: {}
      }
  },
  created() {
      // 类型字典1
      this.getDicts('main_body_type').then(response => {
        response.data.forEach(item => {
          this.investorsTypeOptions.push(item)
        })
      })
      // 类型字典2
      this.getDicts('lp_type').then(response => {
        response.data.forEach(item => {
          this.investorsTypeOptions.push(item)
        })
      })
  },
  methods: {
    /** 查询划款明细列表 */
    getList() {
        this.loading = true
        listDealPaymentDetail(this.queryParams).then(response => {
            this.dealPaymentDetailList = response.rows
            this.total = response.total
            this.loading = false
        })
    },
    // 出资人类型
    investorsTypeOptionsFormat(row) {
      return this.selectDictLabel(this.investorsTypeOptions, row.investorsType)
    },
    getDealPaymentDetail(row) {
      this.loading = true
      this.queryParams.dealPaymentId = row.id || row.paymentId
      listDealPaymentDetail(this.queryParams).then(response => {
        this.dealPaymentDetailList = response.rows
        this.total = response.total
        if (response.rows.length > 0) {
          if (response.rows[0] === null) {
            this.dealPaymentDetailList = []
            this.total = 0
          }
        }
        this.loading = false
      })
    },
    // 表单重置
    reset() {
        this.form = {
            id: undefined,
            fundId: undefined,
            dealPaymentId: undefined,
            dealPaymentInvestorId: undefined,
            investorId: undefined,
            calculationBase: undefined,
            actualPaymentMoney: undefined,
            remark: undefined,
            createBy: undefined,
            createTime: undefined,
            updateBy: undefined,
            updateTime: undefined
        }
        this.resetForm('form')
    }
  }
}
</script>
